/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AdminUI.java
 *
 * Created on Aug 10, 2011, 6:31:47 PM
 */
package hellselevator;

import java.awt.Component;
import javax.swing.JOptionPane;

/**
 *
 * @author Danny
 */
public class AdminUI extends javax.swing.JPanel {
    private Component frame;

    /** Creates new form AdminUI */
    public AdminUI() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        adminHeaderLbl = new javax.swing.JLabel();
        numElevatorsLbl = new javax.swing.JLabel();
        minFloorLbl = new javax.swing.JLabel();
        maxFloorLbl = new javax.swing.JLabel();
        numElevators = new javax.swing.JSpinner();
        minFloorChoice = new javax.swing.JSpinner();
        maxFloorChoice = new javax.swing.JSpinner();
        startBttn = new javax.swing.JButton();

        adminHeaderLbl.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        adminHeaderLbl.setText("Enter elevator parameters:");

        numElevatorsLbl.setText("No. of elevators:");

        minFloorLbl.setText("Minimum floor");

        maxFloorLbl.setText("Maximum floor:");

        maxFloorChoice.setEditor(new javax.swing.JSpinner.NumberEditor(maxFloorChoice, ""));

        startBttn.setText("Start");
        startBttn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startBttnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(177, Short.MAX_VALUE)
                .addComponent(startBttn)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(adminHeaderLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(maxFloorLbl)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(maxFloorChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(minFloorLbl)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(minFloorChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(numElevatorsLbl)
                                .addGap(28, 28, 28)
                                .addComponent(numElevators, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(57, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(adminHeaderLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(numElevatorsLbl)
                    .addComponent(numElevators, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(minFloorLbl)
                    .addComponent(minFloorChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(maxFloorLbl)
                    .addComponent(maxFloorChoice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                .addComponent(startBttn)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

private void startBttnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startBttnActionPerformed
int minFloorNum = Integer.parseInt((String)minFloorChoice.getValue());
int maxFloorNum = Integer.parseInt((String)maxFloorChoice.getValue());
if (minFloorNum > maxFloorNum) {
   JOptionPane.showMessageDialog(frame, "You can not have a greater max floor value then the min floor value","Inane error",JOptionPane.ERROR_MESSAGE);    
}
else {
    Elevator e1 = new Elevator(minFloorNum, maxFloorNum);    
}
}//GEN-LAST:event_startBttnActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel adminHeaderLbl;
    private javax.swing.JSpinner maxFloorChoice;
    private javax.swing.JLabel maxFloorLbl;
    private javax.swing.JSpinner minFloorChoice;
    private javax.swing.JLabel minFloorLbl;
    private javax.swing.JSpinner numElevators;
    private javax.swing.JLabel numElevatorsLbl;
    private javax.swing.JButton startBttn;
    // End of variables declaration//GEN-END:variables

    void run() {
        setVisible(true);
    }
}